package com.authine.cloudpivot.ext.dto.system;

import com.authine.mvp.app.launcher.domain.SelectorFormat;
import com.authine.mvp.app.org.dto.domainmodel.UnitType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName UserDto
 * @Description: 用户
 * @Author fj
 * @Date 2021/5/4
 * @Version V1.0
 **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "UserDto")
public class UserDto {
    @Schema(description = "用户id")
    private String id;
    @Schema(description = "资金账户id")
    private String account_id;
    @Schema(description = "组织id")
    private List<SelectorFormat> organization_id;
    @Schema(description = "部门id")
    private List<SelectorFormat> department_id;
    @Schema(description = "客户端id")
    private String client_id;
    @Schema(description = "角色ID列表")
    private String role_ids;
    @Schema(description = "组织名称")
    private String organization_name;
    @Schema(description = "部门名称")
    private String department_name;
    @Schema(description = "用户名")
    private String username;
    @Schema(description = "手机号")
    private String cellphone;
    @Schema(description = "邮箱")
    private String email;
    @Schema(description = "密码")
    private String password;
    @Schema(description = "登录后重设密码")
    private Boolean login_reset_password;
    @Schema(description = "全名")
    private String fullname;
    @Schema(description = "QQ")
    private String qq;
    @Schema(description = "账户过期")
    private Boolean expired;
    @Schema(description = "账户锁定")
    private Boolean locked;
    @Schema(description = "凭证过期")
    private Boolean credentials_expired;
    @Schema(description = "是否可用")
    private Boolean enabled;
    @Schema(description = "协议账号")
    private Boolean protocol_account;
    @Schema(description = "工号")
    private String job_number;
    @Schema(description = "公钥下标")
    private String index;
    @Schema(description = "角色名称，查询用")
    private String roleName;
    @Schema(description = "用户id，查询用")
    private String memberId;
    @Schema(description = "加密后的新密码，修改密码用")
    private String encryptedNewPassword;
    @Schema(description = "加密后的旧密码，修改密码用")
    private String encryptedOldPassword;

    public SelectorFormat createSelectorFormat() {
        SelectorFormat selectorFormat = new SelectorFormat();
        selectorFormat.setName(fullname);
        selectorFormat.setId(id);
        selectorFormat.setType(UnitType.USER.getIndex());
        return selectorFormat;
    }

    public List<SelectorFormat> createSelectorFormatList() {
        return Collections.singletonList(createSelectorFormat());
    }
}
